﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace simpleHotel.Business
{
    public class Singleton
    {
        private static SimpleHotelDataContext _dataContext;
        /// <summary>
        /// Get model SimpleHotel co san trong he thong.
        /// </summary>
        public static SimpleHotelDataContext DataContext
        { 
            get
            {
                if (_dataContext == null)
                    _dataContext = new SimpleHotelDataContext(ConfigurationManager.ConnectionStrings["SimpleHotel_ConStr"].ConnectionString);
                return _dataContext;
            }
        }

        /// <summary>
        /// Tao moi 1 model SimpleHotel
        /// </summary>
        /// <returns></returns>
        public static SimpleHotelDataContext NewDataContext()
        {
            return new SimpleHotelDataContext(ConfigurationManager.ConnectionStrings["SimpleHotel_ConStr"].ConnectionString);
        }

    }
}
